import React , {Component}from 'react';
import { Modal, Button } from 'antd';
import InputBox from '../../common/InputBox.js'
import  Confirm from '../../common/Confirm.js'


export default class Createpart extends React.Component {
    constructor(props){
        super(props);
        this.state = { visible: false }
        this.Style={};
        this.inputText='';
    }

    componentWillMount() {
        this.Style.createpartview={
            textAlign:"center",
            display:"block",
            border:"3px solid green"
        }
        this.Style.createpartview.border = "3px solid red";
        this.Style.createpartview.width = 400;
        this.Style.createpartview.height = 200;
        this.Style.createpartview.fontSize = 30;



        this.Style.headerview={
            width:"634px",
            height:"44px",
            paddingLeft:"18px",
            lineHeight:"44px",
            display:"block",
            background:"#f2f2f2",
            marginBottom:49,


        }
    }

    state = { visible: false }
    showModal = () => {
        this.setState({
            visible: true,
        });
    }
    handleOk = (e) => {
        console.log(e);
        this.setState({
            visible: false,
        });
    }
    handleCancel = (e) => {
        console.log(e);
        this.setState({
            visible: false,
        });
    }
    createpart(){
        this.inputText = this.refs.departmentName.state.text;
        this.setState({
            visible:false,
        });
       
        let name = this.refs.departmentName.state.text;
        let description = this.refs.departmentdescription.state.text;
        //执行createpart组件的props程序

        this.props.addDepartment(name,description);
        this.refs.departmentName.setState({
            text:"",
        });
        this.refs.departmentdescription.setState({
            text:"",
        })
    }

    render(){
        return (
            <Modal visible={this.state.visible} onOk={this.handleOk} onCancel={this.handleCancel} style={{width:"634px",height:"240px",display:"block"}} title={"新建部门"}>
                <InputBox ref={'departmentName'} defaultvalute="" titletext="部门名称" space="12px" style={{width:338,height:30,borderColor:"#d7d7d7",color:"#999",marginTop:"20px",paddingRight:123}}/>
                <InputBox ref={'departmentdescription'} defaultvalute="" titletext="部门描述" space="12px" style={{rows:5,width:338,height:115,resize:"none",outline:"none",marginTop:30,paddingRight:123}} value={this.state.text} multiline={true}/>
                <Confirm tcontext="确定" style={{width:130,height:40,display:"block",color:"#fff",fontSize:"16px",marginTop:60,marginLeft:124}} touch={this.createpart.bind(this)}/>
            </Modal>
        )
    }
}





